<%
'------------------------------------------------------------------------------------------------------------------------------------
'------------------------------------------------------------------------------------------------------------------------------------
'------------------------------------------------------------------------------------------------------------------------------------

Function ReturnEmailAddress(EmailAddress)
On Error Resume Next
  sSQL = "SELECT fun_usuario FROM Funcionario WHERE fun_usuario = '"& EmailAddress &"'"
  MAT = MatrixBD(sSQL, 1)
  If VarType(MAT) = 8 then
    filas = -1
  Else
    filas = UBound(MAT, 2)
  End If
  if filas <> -1 then
    cadena = MAT(0,0)
  else
    cadena = ""
  end if
  ReturnEmailAddress = cadena
End Function

'------------------------------------------------------------------------------------------------------------------------------------
'------------------------------------------------------------------------------------------------------------------------------------
'------------------------------------------------------------------------------------------------------------------------------------

Function ReturnPassword(Password)
On Error Resume Next
  sSQL = "SELECT fun_password FROM Funcionario WHERE fun_password = '"& Password &"'"
  MAT = MatrixBD(sSQL, 1)
  If VarType(MAT) = 8 then
    filas = -1
  Else
    filas = UBound(MAT, 2)
  End If
  if filas <> -1 then
    cadena = MAT(0,0)
  else
    cadena = ""
  end if
  ReturnPassword = cadena
End Function

'------------------------------------------------------------------------------------------------------------------------------------
'------------------------------------------------------------------------------------------------------------------------------------
'------------------------------------------------------------------------------------------------------------------------------------

Function ReturnRoles(EmailAddress, Password)
On Error Resume Next
  sSQL = "SELECT fun_rol1, fun_rol2, fun_rol3, fun_rol4, fun_rol5, fun_rol6, fun_rol7, fun_rol8, fun_rol9, fun_rol10 FROM Funcionario WHERE (fun_password = '"& Password &"') AND (fun_usuario = '"& EmailAddress &"')"
  MAT = MatrixBD(sSQL, 1)
  If VarType(MAT) = 8 then
    filas = -1
  Else
    filas = UBound(MAT, 2)
  End If
  if filas <> -1 then
    cadena = MAT(0,0)&""&MAT(1,0)&""&MAT(2,0)&""&MAT(3,0)&""&MAT(4,0)&""&MAT(5,0)&""&MAT(6,0)&""&MAT(7,0)&""&MAT(8,0)&""&MAT(9,0)
  else
    cadena = ""
  end if
  ReturnRoles = cadena
End Function

'------------------------------------------------------------------------------------------------------------------------------------
'------------------------------------------------------------------------------------------------------------------------------------
'------------------------------------------------------------------------------------------------------------------------------------

Function ReturnGestion()
On Error Resume Next
  sSQL = "SELECT conf_gestion FROM Configuracion WHERE (conf_estado = 1)"
  MAT = MatrixBD(sSQL, 1)
  If VarType(MAT) = 8 then
    filas = -1
  Else
    filas = UBound(MAT, 2)
  End If
  if filas <> -1 then
    cadena = MAT(0,0)
  else
    cadena = ""
  end if
  ReturnGestion = cadena
End Function

'------------------------------------------------------------------------------------------------------------------------------------
'------------------------------------------------------------------------------------------------------------------------------------
'------------------------------------------------------------------------------------------------------------------------------------

Function ReturnMes()
On Error Resume Next
  sSQL = "SELECT conf_mes FROM Configuracion WHERE (conf_estado = 1)"
  MAT = MatrixBD(sSQL, 1)
  If VarType(MAT) = 8 then
    filas = -1
  Else
    filas = UBound(MAT, 2)
  End If
  if filas <> -1 then
    cadena = MAT(0,0)
  else
    cadena = ""
  end if
  ReturnMes = cadena
End Function

'------------------------------------------------------------------------------------------------------------------------------------
'------------------------------------------------------------------------------------------------------------------------------------
'------------------------------------------------------------------------------------------------------------------------------------

Function ReturnMesOtro()
On Error Resume Next
  sSQL = "SELECT conf_mes_otro FROM Configuracion WHERE (conf_estado = 1)"
  MAT = MatrixBD(sSQL, 1)
  If VarType(MAT) = 8 then
    filas = -1
  Else
    filas = UBound(MAT, 2)
  End If
  if filas <> -1 then
    cadena = MAT(0,0)
  else
    cadena = ""
  end if
  ReturnMesOtro = cadena
End Function

'------------------------------------------------------------------------------------------------------------------------------------
'------------------------------------------------------------------------------------------------------------------------------------
'------------------------------------------------------------------------------------------------------------------------------------

Function ReturnInsumosCerrados()
On Error Resume Next
  sSQL = "SELECT cerrado_insumos FROM Configuracion WHERE (conf_estado = 1)"
  MAT = MatrixBD(sSQL, 1)
  If VarType(MAT) = 8 then
    filas = -1
  Else
    filas = UBound(MAT, 2)
  End If
  if filas <> -1 then
    cadena = MAT(0,0)
  else
    cadena = ""
  end if
  ReturnInsumosCerrados = cadena
End Function

'------------------------------------------------------------------------------------------------------------------------------------
'------------------------------------------------------------------------------------------------------------------------------------
'------------------------------------------------------------------------------------------------------------------------------------

Function ReturnUnidad(EmailAddress, Password)
On Error Resume Next
  sSQL = "SELECT f.uni_id, u.uni_unidad FROM Funcionario f JOIN UnidadOrganizacional u ON u.uni_id=f.uni_id WHERE (f.fun_password = '"& Password &"') AND (f.fun_usuario = '"& EmailAddress &"')"
  MAT = MatrixBD(sSQL, 1)
  If VarType(MAT) = 8 then
    filas = -1
  Else
    filas = UBound(MAT, 2)
  End If
  Dim myArray(1)
  if filas <> -1 then
    myArray(0) = MAT(0,0)
    myArray(1) = MAT(1,0)
  else
    myArray(0) = ""
    myArray(1) = ""
  end if
  ReturnUnidad = myArray
End Function

'------------------------------------------------------------------------------------------------------------------------------------
'------------------------------------------------------------------------------------------------------------------------------------
'------------------------------------------------------------------------------------------------------------------------------------

Function ReturnApertura(EmailAddress, Password)
On Error Resume Next
  sSQL = "SELECT u.aper_id, a.aper_descripcion FROM Funcionario f JOIN UnidadOrganizacional u ON u.uni_id=f.uni_id JOIN AperturaProgramatica a ON a.aper_id=u.aper_id WHERE (f.fun_password = '"& Password &"') AND (f.fun_usuario = '"& EmailAddress &"')"
  MAT = MatrixBD(sSQL, 1)
  If VarType(MAT) = 8 then
    filas = -1
  Else
    filas = UBound(MAT, 2)
  End If
  Dim myArray(1)
  if filas <> -1 then
    myArray(0) = MAT(0,0)
    myArray(1) = MAT(1,0)
  else
    myArray(0) = ""
    myArray(1) = ""
  end if
  ReturnApertura = myArray
End Function

'------------------------------------------------------------------------------------------------------------------------------------
'------------------------------------------------------------------------------------------------------------------------------------
'------------------------------------------------------------------------------------------------------------------------------------

Function ReturnIDUsuario(EmailAddress, Password)
On Error Resume Next
  sSQL = "SELECT fun_id FROM Funcionario WHERE (fun_password = '"& Password &"') AND (fun_usuario = '"& EmailAddress &"')"
  MAT = MatrixBD(sSQL, 1)
  If VarType(MAT) = 8 then
    filas = -1
  Else
    filas = UBound(MAT, 2)
  End If
  if filas <> -1 then
    cadena = MAT(0,0)
  else
    cadena = ""
  end if
  ReturnIDUsuario = cadena
End Function

%>